package JVM;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ScheduleMain {

    public static void main(String[] args){
        ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
        ses.scheduleAtFixedRate(new TimerTask(),0, 10, TimeUnit.SECONDS);
    }

    static class TimerTask implements Runnable {

        @Override
        public void run() {
            {
                System.out.println("run");
                byte[] holder = new byte[32 * 1024 * 1024];
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                holder = null;
            }
            System.gc();
        }
    }


}
